package ModelLayer;


import java.util.ArrayList;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The test class DVDRecordsTest.
 *
 * @author  (your name)
 * @version (a version number or a date)
 */
public class DVDRecordsTest
{
    /**
     * Default constructor for test class DVDRecordsTest
     */
    public DVDRecordsTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
    }

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {
    }
    
     @Test
    public void testGetInstance()
    {
        assertNotNull(ModelLayer.DVDRecords.getInstance());
    }
     
    
    
    @Test
    public void testRemoveDVD()
    {
        DVD dvd = new DVD();
        boolean status = false;
        dvd.setId(1);
        ModelLayer.DVDRecords.getInstance().removeDVD(1);
        ArrayList<DVD> dvds = ModelLayer.DVDRecords.getInstance().getDVDList();
        
        for (DVD curDVD : dvds)
        {
            if (curDVD==dvd) status = true;
            else status = false;
        }
        assertFalse("Test fails",status);
        }
        
    
    @Test
    public void testAddDVD()
    {
        DVD dvd = new DVD ();
        boolean status = false;
        DVDRecords.getInstance().addDVD(dvd);
        ArrayList<DVD> dvds = DVDRecords.getInstance().getDVDList();
        for (DVD curDVD : dvds)
        {
            if (curDVD==dvd) status = true;
            else status = false;
        }
        assertTrue(status);
    }
    
 
    @Test
    public void testUpdateDVD()
    {
        DVD dvd = new DVD(1,"manol","manolov",1789);
        DVDRecords.getInstance().addDVD(dvd);
        DVDRecords.getInstance().updateDVD(1,1,"madalin4o");
        assertEquals("madalin4o",DVDRecords.getInstance().getDVD(1).getTitle());
    }
    
    @Test
    public void testCreateDVD()
    {
        DVDRecords.getInstance().createDVD(1, "Hot", "Nelly", 12335);
        assertNotNull(DVDRecords.getInstance().getDVD(1));
    }
}
